﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Xml;
using System.Data;
using System.Configuration;

using Gift.DAL;
using Gift.Model;
using Gift.WebApp;

public partial class cn_UserControl_channel_navigation : System.Web.UI.UserControl
{

    protected string xmlPath = "/cn/xml/channel.xml";

    // Methods
    protected StringBuilder CategoryBestBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.Request.QueryString["cid"] == null)
            {
                return builder;
            }
            DataTable table = BaseFactory.theGoods.GetGoodsByCategoryAndIsShelvesAndIsNewAndTop(base.Request.QueryString["cid"], 1, 15, 1);
            if (table.Rows.Count > 0)
            {
                DataTable categoryById = BaseFactory.theCategory.GetCategoryById(base.Request.QueryString["cid"]);
                builder.AppendLine("<div class=\"prolist container\">");
                builder.AppendLine("<h5 class=\"chanelnewspro\"><strong>新品上市</strong><span>New Arrival</span><a href=\"/cn/goods_list.html?cid=" + categoryById.Rows[0]["categoryIdentity"] + "\" title=\"查看更多\">查看更多&gt;&gt;</a></h5>");
                builder.AppendLine("<ul>");
                foreach (DataRow row in table.Rows)
                {
                    builder.AppendLine("<li>");
                    builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", row["id"], "\"  name=\"#hoverinfo", row["id"], "\" class=\"pro_img\"><img src=\"", row["thumbImg"], "\" alt=\"", row["imgAlt"], "\" /></a>" }));
                    builder.AppendLine(string.Concat(new object[] { "<p><a href=\"/cn/goods.html?id=", row["id"], "\" title=\"", row["goodsName"], "\">", (row["goodsName"].ToString().Length > 8) ? (row["goodsName"].ToString().Substring(0, 8) + "...") : row["goodsName"], "</a><span>市场价", string.Format("{0:C}", Convert.ToDecimal(row["marketPrice"])), "</span><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])), "</strong></em></p>" }));
                    builder.AppendLine(string.Concat(new object[] { "<div id=\"hoverinfo", row["id"], "\" style=\"display: none;\"><img src=\"", row["thumbImg"], "\" alt=\"", row["goodsName"], "\" /><p><strong>", row["goodsName"], "</strong> <span>产品编号:", row["goodsNo"], "</span> <span>会员价：<em>", string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])), "</em></span><span><del>市场价", string.Format("{0:C}", Convert.ToDecimal(row["marketPrice"])), "</del></span></p></div>" }));
                    builder.AppendLine("</li>");
                }
                builder.AppendLine("</ul>");
                builder.AppendLine("<span class=\"clear\"></span>");
                builder.AppendLine("</div>");
            }
            int num = Convert.ToInt32(ConfigurationManager.AppSettings["ChannelCategoryMaxCount"]);
            DataTable table3 = BaseFactory.theCategory.GetCategoryByParentIdAndCompanyIdAndIsShow(base.Request.QueryString["cid"], new BasePage().CompanyId, 1);
            DataTable categoryAdByCategory = BaseFactory.theCategoryAd.GetCategoryAdByCategory(base.Request.QueryString["cid"]);
            int num2 = 0;
            for (int i = 0; i < table3.Rows.Count; i++)
            {
                if (i >= num)
                {
                    continue;
                }
                DataRow row2 = table3.Rows[i];
                DataTable table5 = BaseFactory.theGoods.GetGoodsByCategoryAndIsShelvesAndIsBestAndTop(row2["id"].ToString(), 1, 1, 6);
                if (table5.Rows.Count > 0)
                {
                    if (num2 == 1)
                    {
                        builder.AppendLine("<div class=\"container\"><a href=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["middleUrl"].ToString() : "#") + "\" target=\"_blank\"><img src=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["middle"].ToString() : "/cn/category_ad/ChannelMiddle.jpg") + "\" alt=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["middleAlt"].ToString() : "") + "\"/></a></div>");
                    }
                    builder.AppendLine("<div class=\"prolist container\">");
                    builder.AppendLine("<h5>");
                    builder.AppendLine(string.Concat(new object[] { "<strong>", row2["categoryName"], "\x00b7推荐</strong><a href=\"goods_list.html?cid=", row2["categoryIdentity"], "\" title=\"查看更多\">查看更多&gt;&gt;</a>" }));
                    builder.AppendLine("</h5>");
                    switch (num2)
                    {
                        case 0:
                            builder.AppendLine("<a href=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryOneUrl"].ToString() : "#") + "\" target=\"_blank\"><img class=\"float\" src=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryOne"].ToString() : "/cn/category_ad/ChannelCategory1.jpg") + "\" alt=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryOneAlt"].ToString() : "") + "\" /></a>");
                            break;

                        case 1:
                            builder.AppendLine("<a href=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryTwoUrl"].ToString() : "#") + "\" target=\"_blank\"><img class=\"float\" src=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryTwo"].ToString() : "/cn/category_ad/ChannelCategory2.jpg") + "\" alt=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryTwoAlt"].ToString() : "") + "\" /></a>");
                            break;

                        case 2:
                            builder.AppendLine("<a href=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryThreeUrl"].ToString() : "#") + "\" target=\"_blank\"><img class=\"float\" src=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryThree"].ToString() : "/cn/category_ad/ChannelCategory3.jpg") + "\" alt=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryThreeAlt"].ToString() : "") + "\" /></a>");
                            break;

                        case 3:
                            builder.AppendLine("<a href=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryFourUrl"].ToString() : "#") + "\" target=\"_blank\"><img class=\"float\" src=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryFour"].ToString() : "/cn/category_ad/ChannelCategory4.jpg") + "\" alt=\"" + ((categoryAdByCategory.Rows.Count > 0) ? categoryAdByCategory.Rows[0]["categoryFourAlt"].ToString() : "") + "\" /></a>");
                            break;
                    }
                    builder.AppendLine("<ul>");
                    foreach (DataRow row3 in table5.Rows)
                    {
                        builder.AppendLine("<li>");
                        builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", row3["id"], "\"  name=\"#hoverinfo", row3["id"], "\" class=\"pro_img\"><img src=\"", row3["thumbImg"], "\" alt=\"", row3["imgAlt"], "\" /></a>" }));
                        builder.AppendLine(string.Concat(new object[] { "<p><a href=\"/cn/goods.html?id=", row3["id"], "\" title=\"", row3["goodsName"], "\">", (row3["goodsName"].ToString().Length > 8) ? (row3["goodsName"].ToString().Substring(0, 8) + "...") : row3["goodsName"], "</a><span>市场价", string.Format("{0:C}", Convert.ToDecimal(row3["marketPrice"])), "</span><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row3["salePrice"])), "</strong></em></p>" }));
                        builder.AppendLine(string.Concat(new object[] { "<div id=\"hoverinfo", row3["id"], "\" style=\"display: none;\"><img src=\"", row3["thumbImg"], "\" alt=\"", row3["goodsName"], "\" /><p><strong>", row3["goodsName"], "</strong> <span>产品编号:", row3["goodsNo"], "</span> <span>会员价：<em>", string.Format("{0:C}", Convert.ToDecimal(row3["salePrice"])), "</em></span><span><del>市场价", string.Format("{0:C}", Convert.ToDecimal(row3["marketPrice"])), "</del></span></p></div>" }));
                        builder.AppendLine("</li>");
                    }
                    builder.AppendLine("</ul>");
                    builder.AppendLine("<span class=\"clear\"></span>");
                    builder.AppendLine("</div>");
                    num2++;
                }
            }
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}